﻿namespace IOP.OpenType
{
    /// <summary>
    /// 	Long offset to a table, same as uint32, NULL offset = 0x00000000
    /// </summary>
    public readonly struct Offset32
    {
        /// <summary>
        /// 
        /// </summary>
        public readonly uint origin;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="number"></param>
        public Offset32(uint number) => origin = number;

        /// <summary>
        /// 隐式转换
        /// </summary>
        public static implicit operator uint(Offset32 offset) => offset.origin;
        /// <summary>
        /// 隐式转换
        /// </summary>
        public static implicit operator int(Offset32 offset) => (int)offset.origin;
        /// <summary>
        /// 隐式转换
        /// </summary>
        /// <param name="number"></param>
        public static implicit operator Offset32(int number) => new Offset32((uint)number);
        /// <summary>
        /// 隐式转换
        /// </summary>
        /// <param name="number"></param>
        public static implicit operator Offset32(uint number) => new Offset32(number);
        /// <summary>
        /// NULL
        /// </summary>
        public static Offset32 NULL => new Offset32(0x00000000);
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override string ToString() => origin.ToString();
    }
}
